﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using YJKStairs.DataInfos;

namespace YJKStairs.Manage
{
	public class StairsLandingCreator
	{
		public static void CreateLanding(ElementId stairsId, Autodesk.Revit.DB.Document doc, double topElevation, List<CurveInfo> boundaryCurvesInfoList)
		{
			if (boundaryCurvesInfoList.Count == 0)
			{
				return;
			}
			CurveLoop curveLoop = CurveLoop.Create(StairsLandingCreator.GetCurvesByCurvesInfo(boundaryCurvesInfoList));
			StairsLanding.CreateSketchedLanding(doc, stairsId, curveLoop, topElevation);
			doc.Regenerate();
		}

		private static List<Curve> GetCurvesByCurvesInfo(List<CurveInfo> curvesInfoList)
		{
			List<Curve> list = new List<Curve>();
			foreach (CurveInfo curveInfo in curvesInfoList)
			{
				list.Add(curveInfo.CurveObj);
			}
			return list;
		}
	}
}
